package cn.gson.boot.model.service;

import cn.gson.boot.model.dao.UserDao;
import cn.gson.boot.model.mapper.KehuMapper;
import cn.gson.boot.model.mapper.UserMapper;
import cn.gson.boot.model.pojos.User;
import cn.gson.boot.model.pojos.Work;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(rollbackFor = Exception.class)
public class UserService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    KehuMapper kehuMapper;
    //分页查询和模糊查询
    public List<User> allusers(String empName){
        return userMapper.allusers(empName);
    }

    //按周月排行时间段查询
    public List<User> allshijian(String Start,String Over,String empName,int empId){
        return userMapper.allshijian(Start,Over,empName,empId);
    }

    // 修改客户负责人
    public void updateUser(Integer[] customIdArr,Integer empId){
        for (int i=0;i<customIdArr.length;i++) {
            System.out.println(customIdArr[i]);
            Integer customId=customIdArr[i];
            kehuMapper.updateUser(empId,customId);
        }
    }

    //统计图按用户查询新建数
    public Map<String,Object> empXinjians(String Start,String Over){
        Map<String,Object> map = new HashMap<>();
        List<Integer> shu = new ArrayList<>();//新增数量
        List<BigDecimal> jine = new ArrayList<>();//新增金额总量
        List<String> mz = new ArrayList<>();//员工名字
        return null;
    }
}
